window.onload = function() {
	var pinkHeight = $(document).height(),
		pinkWidth = $(document).width(),
		timer = null,
		timer1 = null,
		timer3 = null,
		enterNav = document.getElementById('enter-nav'),
		judge = true,
		judge2 = false,
		judge3 = true; 
	// 视口宽度
	$(".enter-wrapper").css({
		"height" : pinkHeight
	});
	$(".enter-wrapper").css({
		"width" : pinkWidth
	});


	$(".enter-box div").css({
		"height" : pinkHeight
	});

	$(window).resize(function() {
		var boxHeight = $(document).height(),
			boxWidth = $(document).width();

			pinkHeight = boxHeight;
			pinkWidth = boxWidth;
		$(".enter-wrapper").css({
			"height" : boxHeight
		});
		$(".enter-wrapper").css({
			"width" : boxWidth
		});
		$(".enter-box div").css({
			"height" : boxHeight
		});
		
	})
		
	
	

	// page1 出现功能
	function moveInCream () {
		
		$(".enter-cream1-1").css({
		"display" : "block"
		});
		$(".enter-cream1-1").stop(true, true).animate({
			"left" : "718px"
		},600, function() {
			$(".enter-cream1").css({
				"display" : "block"
			});
			$(".enter-cream1").stop(true, true).animate({
				"top" : "0px"
			},600, function() {
				$(".enter-cream2").css({
					"display" : "block"
				});
				$(".enter-cream2").stop(true, true).animate({
					"left" : "43px"
				},600, function() {
					$(".enter-cream3").css({
						"display" : "block"
					});
					$(".enter-cream3").stop(true, true).animate({
						"left" : "233px"
					},600, function() {
						$(".enter-cream4").css({
							"display" : "block"
						});
						$(".enter-cream4").stop(true, true).animate({
							"top" : "-81px"
						},600, function() {
							if(judge) {
								timer1 = setTimeout(moveCream,3500);
								
							}
						});
					})
				})
			});
		})
	}
	timer3 = setTimeout(moveInCream,100);

function count0() {
		$(".enter-wrapper").stop(true, true).animate({
			"scrollTop" : 0
		});
}

function count1() {
		$(".enter-wrapper").stop(true, true).animate({
			"scrollTop" : pinkHeight
		});
}
function count2() {
		$(".enter-wrapper").stop(true, true).animate({
			"scrollTop" : pinkHeight * 2
		});
	}
function count3() {
		$(".enter-wrapper").stop(true, true).animate({
			"scrollTop" : pinkHeight * 3
		});
	}

	
	$(".enter-nav li").eq(0).click(function() {
		if(judge3) {
			judge3 = false;
			judge = false; //取消自动撤销功能
			$(this).attr("id", "enter-nav").siblings().removeAttr("id", "enter-nav");
			count0();
			moveInCream(); //相应模块出现功能
			// 以下为撤销功能
			moveBlue();
			movePink();
			moveRed();
			judge3 = true;
		}
	});
		
	
	
	$(".enter-nav li").eq(1).click(function() {
		if(judge3) {
			judge3 = false;
			judge = false;
			$(this).attr("id", "enter-nav").siblings().removeAttr("id", "enter-nav");
			count1();
			moveInBlue(); //相应模块出现功能
			// 以下为相应模块撤销功能
			moveCream();
			movePink();
			moveRed();
			judge3 = true;
			
		}
	})
		


	$(".enter-nav li").eq(2).click(function() {
		if(judge3) {
			judge3 = false;
			judge = false;
			$(this).attr("id", "enter-nav").siblings().removeAttr("id", "enter-nav");
			count2();
			moveInRed(); //相应模块出现功能
			// 以下为相应模块撤销功能
			moveCream();
			movePink();
			moveBlue();
			judge3 = true;
			
		}
	})
		
	
	
	$(".enter-nav li").eq(3).click(function() {
		if(judge3) {
			judge3 = false;
			judge = false;
			$(this).attr("id", "enter-nav").siblings().removeAttr("id", "enter-nav");
			count3();
			moveInPink(); //相应模块出现功能
			// 以下为相应模块撤销功能
			moveCream();
			moveBlue();
			moveRed();
			judge3 = true;
			
		}
	})
		
	
// page1撤销功能
function moveCream() {
		
		$(".enter-cream1-1").stop(true, true).animate({
			"left" : "1363px"
		},600, function() {
			$(".enter-cream1-1").css({
				"display" : "none"
			});
		});

		$(".enter-cream1").stop(true, true).animate({
			"top" : "-650px"
		},600,function() {
			$(".enter-cream1").css({
				"display" : "none"
			});
		});

		$(".enter-cream2").stop(true, true).animate({
			"left" : "-990px"
		},600,function() {
			$(".enter-cream2").css({
				"display" : "none"
			});
		});

		$(".enter-cream3").stop(true, true).animate({
			"left" : "-656px"
		},600,function() {
			$(".enter-cream3").css({
				"display" : "none"
			});	
		});
		$(".enter-cream4").stop(true, true).animate({
			"top" : "-800px"
		},600,function() {
			$(".enter-cream4").css({
				"display" : "none"
			});	
			if(judge) {
				$(".enter-nav li").eq(1).attr("id", "enter-nav").siblings().removeAttr("id", "enter-nav");
				timer = setTimeout(count1, 600);
				timer1 = setTimeout(moveInBlue,1200);
				
			}
		});
		
	}
		

	//page2 出现功能
function moveInBlue() {
		$(".enter-blue1").css({
			"display" : "block"
		});
		$(".enter-blue1").stop(true, true).animate({
			"right" : "40px"
		},600, function() {
			$(".enter-blue2").css({
				"display" : "block"
			});
			$(".enter-blue2").stop(true, true).animate({
				"top" : "172px"
			},600, function() {
				$(".enter-blue3").css({
					"display" : "block"
				});
				$(".enter-blue3").stop(true, true).animate({
					"top" : "-94px"
				},600,function() {
					if(judge) {
						timer1 = setTimeout(moveBlue, 3500);
						
					}
				})
			});
		});	
	}
//page2 元素撤销功能
function moveBlue() {
	$(".enter-blue1").stop(true,true).animate({
		"right" : "-720px"
	},600, function() {
		$(".enter-blue1").css({
			"display" : "none"
		});
	});
	$(".enter-blue2").stop(true,true).animate({
		"top" : "658px"
	},600, function() {
		$(".enter-blue2").css({
			"display" : "none"
		});
	});
	$(".enter-blue3").stop(true,true).animate({
		"top" : "-658px"
	},600, function() {
		$(".enter-blue3").css({
			"display" : "none"
		});
		if(judge) {
			$(".enter-nav li").eq(2).attr("id", "enter-nav").siblings().removeAttr("id", "enter-nav");
			timer1 = setTimeout(moveInRed,1200);
			timer = setTimeout(count2, 600);
			
		}
	});
}

//page3 出现功能
function moveInRed() {
	$(".enter-red1-1").css({
		"display" : "block"
	});
	$(".enter-red1-1").stop(true,true).animate({
		"left" : "718px"
	},600, function() {
		$(".enter-red1").css({
			"display" : "block"
		});
		$(".enter-red1").stop(true,true).animate({
			"left" : "36px"
		},600, function() {
			$(".enter-red2").css({
				"display" : "block"
			});
			$(".enter-red2").stop(true,true).animate({
				"top" : "40px"
			},600, function() {
				$(".enter-red3").css({
					"display" : "block"
				});
				$(".enter-red3").stop(true,true).animate({
					"left" : "36px"
				},600, function() {
					$(".enter-red4").css({
						"display" : "block"
					});
					$(".enter-red4").stop(true,true).animate({
						"top" : "216px"
					},600, function() {
						if(judge) {
							timer1 = setTimeout(moveRed,3500)
						}
					})
				})
			})
		})
		
	})
}

// page3 元素撤销功能
function moveRed() {
		$(".enter-red1-1").stop(true, true).animate({
			"left" : "1476px"
		},600, function() {
			$(".enter-red1-1").css({
				"display" : "none"
			})
		});

		$(".enter-red1").stop(true, true).animate({
			"left" : "-799px"
		},600,function() {
			$(".enter-red1").css({
				"display" : "none"
			});
		});

		$(".enter-red2").stop(true, true).animate({
			"top" : "-480px"
		},600,function() {
			$(".enter-red2").css({
				"display" : "none"
			});
		});

		$(".enter-red3").stop(true, true).animate({
			"left" : "-785px"
		},600,function() {
			$(".enter-red3").css({
				"display" : "none"
			});	
		});
		$(".enter-red4").stop(true, true).animate({
			"top" : "-638px"
		},600,function() {
			$(".enter-red4").css({
				"display" : "none"
			});	
			if(judge) {
				$(".enter-nav li").eq(3).attr("id", "enter-nav").siblings().removeAttr("id", "enter-nav");
				timer1 = setTimeout(moveInPink,1200);
				timer = setTimeout(count3, 600);
				
			}
		});
}

// page4 出现功能
function moveInPink() {
	$(".enter-pink7-text").css({
		"display" : "block"
	});
	$(".enter-pink7-text").stop(true, true).animate({
		"right" : "4px"
	},600, function() {
		$(".enter-pink1").css({
			"display": "block"
		});
		$(".enter-pink1").stop(true, true).animate({
			"left" : "0px"
		},600, function() {
			$(".enter-pink2").css({
				"display" : "block"
			});
			$(".enter-pink2").stop(true, true).animate({
				"left" : "199px"
			},600, function() {
				$(".enter-pink3").css({
					"display" : "block"
				});
				$(".enter-pink3").stop(true, true).animate({
					"right": "348px"
				},600,function() {
					if(judge) {
						timer1 = setTimeout(movePink, 3500);
					}

				})
			})	
		});
	});
	
}

// page4 元素撤销模块
function movePink() {
		$(".enter-pink7-text").stop(true, true).animate({
			"right" : "-742px"
		},600, function() {
			$(".enter-pink7-text").css({
				"display" : "none"
			});
		});

		$(".enter-pink1").stop(true, true).animate({
			"left" : "-735px"
		},600,function() {
			$(".enter-pink1").css({
				"display" : "none"
			});
		});

		$(".enter-pink2").stop(true, true).animate({
			"left" : "-735px"
		},600,function() {
			$(".enter-pink2").css({
				"display" : "none"
			});
		});

		$(".enter-pink3").stop(true, true).animate({
			"right" : "-680px"
		},600,function() {
			$(".enter-pink3").css({
				"display" : "none"
			});	
			if(judge) {
				$(".enter-nav li").eq(0).attr("id", "enter-nav").siblings().removeAttr("id", "enter-nav");
				timer = setTimeout(count0, 600);
				timer1 = setTimeout(moveInCream,1200);
				
			}
		});
}


}

